package com.market.plus.controller.validator;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.market.plus.core.dto.TribeDto;

@Component("tribeValidator")
public class TribeValidator implements Validator {

   public boolean supports(Class<?> classDef) {
      return TribeDto.class.isAssignableFrom(classDef);
   }

   public void validate(Object object, Errors errors) {
      validateClassDef(object, errors);
   }

   public void validateClassDef(Object object, Errors errors) {
      ValidationUtils.rejectIfEmptyOrWhitespace(errors, "tribe.name", "err.required");
      ValidationUtils.rejectIfEmptyOrWhitespace(errors, "tribe.description", "err.required");

   }
}
